/* defines.cpp */

#include "defines.h"

namespace dodomet
{
namespace mm5
{
std::string ordering_to_string(int ordering_index)
{
	using namespace ordering_names;
	switch (ordering_index)
	{
	case YXP:
		return "YXP";
	case YXS:
		return "YXS";
	case YXW:
		return "YXW";
	case YX:
		return "YX";
	case CA:
		return "CA";
	case XSB:
		return "XSB";
	case YSB:
		return "YSB";
	case XWB:
		return "XWB";
	case YWB:
		return "YWB";
	case P:
		return "P";
	case S:
		return "S";
	default:
		return "UNKNOWN"; 
	}
}

int string_to_ordering(const std::string& ordering_name)
{
        if(ordering_name == "YXP")
                return ordering_names::YXP;
        else if(ordering_name == "YXS")
                return ordering_names::YXS;
        else if(ordering_name == "YXW")
                return ordering_names::YXW;
        else if(ordering_name == "YX")
                return ordering_names::YX;
        else if(ordering_name == "CA")
                return ordering_names::CA;
        else if(ordering_name == "XSB")
                return ordering_names::XSB;
        else if(ordering_name == "YSB")
                return ordering_names::YSB;
        else if(ordering_name == "XWB")
                return ordering_names::XWB;
        else if(ordering_name == "YWB")
                return ordering_names::YWB;
        else if(ordering_name == "P")
                return ordering_names::P;
        else if(ordering_name == "S")
                return ordering_names::S;
        else
                return ordering_names::UNKNOWN; 
}

std::string staggering_to_string(int staggering_index)
{
	using namespace staggering_names;
	switch(staggering_index)
	{
	case C:
		return "C";
	case D:
		return "D";
	default:
		return "UNKNOWN";
	}
}

int string_to_staggering(const std::string& staggering_name)
{
	if(staggering_name == "C")
		return staggering_names::C;
	else if(staggering_name == "D")
		return staggering_names::D;
	else
		return staggering_names::UNKNOWN;
}

int char_to_staggering(char staggering_name)
{
	switch(staggering_name)
	{
	case 'C':
		return staggering_names::C;
	case 'D':
		return staggering_names::D;
	default:
		return staggering_names::UNKNOWN;
	}
}

namespace exceptions
{
cannot_open_file::cannot_open_file(const std::string& filename)
	: what_(filename)
{
}

const char* cannot_open_file::what() const throw()
{
	return what_.c_str();
}

object_uninitialized::object_uninitialized(const std::string& object_what)
	: what_(object_what)
{
}

const char* object_uninitialized::what() const throw()
{
	return what_.c_str();
}
} // namespace dodomet::mm5::exceptions

} // namespace dodomet::mm5
} // namespace dodomet
